<template>
  <view class="container">

    <view class="user-info-box">
      <!-- 顶部区域 -->
      <view class="top-box">
        <image :src="userinfo.avatarUrl" mode=""></image>
        <text>{{userinfo.nickName}}</text>
      </view>
      <!-- 面板区域 -->
      <view class="panel-list">
        <!-- 第一个 -->
        <view class="panel">
          <view class="panel-body">
            <view class="panel-item">
              <text>8</text>
              <text>收藏的店铺</text>
            </view>
            <view class="panel-item">
              <text>8</text>
              <text>收藏的商品</text>
            </view>
            <view class="panel-item">
              <text>44</text>
              <text>关注的商品</text>
            </view>
            <view class="panel-item">
              <text>81</text>
              <text>足迹</text>
            </view>
          </view>
        </view>

        <!-- 第二个 -->
        <view class="panel">
          <view class="title">
            我的订单
          </view>
          <view class="panel-body">
            <view class="panel-item">
              <image src="/static/my-icons/icon1.png" mode=""></image>
              <text>待付款</text>
            </view>
            <view class="panel-item">
              <image src="/static/my-icons/icon2.png" mode=""></image>
              <text>待付款</text>
            </view>
            <view class="panel-item">
              <image src="/static/my-icons/icon3.png" mode=""></image>
              <text>待付款</text>
            </view>
            <view class="panel-item">
              <image src="/static/my-icons/icon4.png" mode=""></image>
              <text>待付款</text>
            </view>
          </view>
        </view>

        <!-- 第三个 -->
        <view class="panel">
          <view class="panel-three-body">
            <view class="panel-three-body-item">
              <text>收货地址</text>
              <uni-icons type="arrowright" size="14"></uni-icons>
            </view>
            <view class="panel-three-body-item">
              <text>联系客服</text>
              <uni-icons type="arrowright" size="14"></uni-icons>
            </view>
            <view @click="layout" class="panel-three-body-item">
              <text>退出登录</text>
              <uni-icons type="arrowright" size="14"></uni-icons>
            </view>
          </view>
        </view>
      </view>
    </view>

  </view>


</template>

<script>
  import {
    mapState,
    mapMutations,
    mapGetters
  } from 'Vuex'
  export default {
    name: "my-user-info",
    computed: {
      ...mapState('m_user', ['userinfo']),
    },
    onLoad() {},
    data() {
      return {};
    },
    methods: {
      ...mapMutations('m_user', ['updateUserinfo', 'updateToken', 'updateAddress']),
      async layout() {
        const res = await uni.showModal({
          title: "提示",
          content: "您确认要退出登录吗?"
        }).catch(err => err)

        if (res.confirm === true) {
          this.updateUserinfo({})

          this.updateAddress({})
          this.updateToken('')
        }
      }

    }
  }
</script>

<style lang="scss">
  .user-info-box {
    height: 100%;
    background-color: whitesmoke;

    .top-box {
      height: 400rpx;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      background-color: #c00000;

      image {
        width: 100px;
        height: 100px;
        border-radius: 50px;
        border: 2px solid white;
      }

      text {
        color: whitesmoke;
        margin-top: 10px;
        font-size: 14px;
      }
    }

    .panel-list {
      transform: translateY(-10px);
      width: 90%;
      margin: 0 auto;
      font-size: 12px;
      padding: 0 10px;

      .panel {
        margin-bottom: 10px;
        background-color: white;

        .title {
          padding-left: 15px;
          line-height: 25px;
          border-bottom: 1px solid #efefef;
        }

        .panel-body {
          height: 100%;
          display: flex;
          justify-content: space-around;
          align-items: center;
          padding: 8PX 0px;

          .panel-item {
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            align-items: center;

            image {
              width: 35px;
              height: 35px;
            }
          }
        }


        .panel-three-body {
          .panel-three-body-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0px 10px;
            line-height: 40px;
            border-bottom: 1px solid #efefef;
          }
        }



      }

    }

  }
</style>